#include "complex.h"
#include "math.h"

Complex::Complex(double re, double im)
{
    this->real = re;
    this->imaginario = im;
}
Complex::Complex(const Complex& other)
{
    this->real = other.real;
    this->imaginario = other.imaginario;
}
Complex& Complex::operator=(const Complex& other){
    this->real = other.real;
    this->imaginario = other.imaginario;
    return (*this);
}
Complex Complex::operator*(const Complex & other)
{
    return Complex (this->real*other.real-(this->imaginario*other.imaginario),this->real*other.imaginario + other.real * this->imaginario);
}
Complex Complex::operator*(double escalar)
{
    Complex res(this->real * escalar,this->imaginario * escalar);
    return res;
}
Complex Complex::operator/(const Complex& other)
{

    double divisor = this->imaginario*this->imaginario + other.imaginario*other.imaginario;
    Complex res((this->real*other.real+(this->imaginario*other.imaginario))/divisor,(this->imaginario*other.real - (this->real*other.imaginario))/divisor);
    return res;
}
Complex Complex::operator/(double escalar)
{
    return this->operator *(1/escalar);
}
Complex Complex::operator-(const Complex& other)
{
    Complex comp(this->real - other.real,this->imaginario - other.imaginario);
    return comp;
}
Complex Complex::operator+(const Complex & other)
{
    Complex comp(this->real + other.real,this->imaginario + other.imaginario);
    return comp;
}
Complex Complex::expo(double tita)
{
    Complex r(cos(tita),-sin(tita));
    return r;
}

bool Complex::operator ==(const Complex & other)
{
    return (this->real==other.real && this->imaginario==other.imaginario);
}

double Complex::moduloALa2()
{
    return (this->real*this->real+this->imaginario*this->imaginario);
}

